import request from '../../utils/request'


/**
 * 获取开票人列表
 * @param cstId
 * @param page
 * @returns {Promise.<void>}
 */
export async function getDrawerListByCstId({ cstId, drawerName, taxplayercode, status, page}) {
    return request(apiPath.mc + "/api/drawers", {
        method: 'get',
        data: {cstId, status, drawerName, taxplayercode, page: page.page, size: page.size}
    });
}

export async function getApprovalDrawerList({ cstId, drawerName, taxplayercode, status, page}) {
    return request(apiPath.mc + "/api/drawers/approval", {
        method: 'get',
        data: {cstId, status, drawerName, taxplayercode, page: page.page, size: page.size}
    });
}

/**
 * 获取开票人列表
 * @param cstId
 * @returns {Promise.<void>}
 */
export async function getDrawerList({cstId, drawerName, taxplayercode, status}) {
    return request(apiPath.mc + "/api/drawers/all", {
        method: 'get',
        data: {cstId, status, drawerName, taxplayercode}
    });
}


/**
 * 增加开票人
 * @param taxplayercode
 * @param name
 * @param identifitime
 * @param exportvolume
 * @param exportvolumecurrency
 * @param workshop
 * @param staffnum
 * @param financialcontactor
 * @param financialtelephone
 * @param province
 * @param district
 * @param address
 * @param website
 * @param ischeckinfo
 * @param contactname
 * @param contacttel
 * @param certInfoBussinessLicense
 * @param certInfoReceipt
 * @param certInfoSaleCheck
 * @param certInfoTaxplayer
 * @param certInfoVATVoice
 * @param certInfoProtocal
 * @param certInfoOther
 * @param cstid
 * @returns {Promise.<void>}
 */
export async function addDrawer({
                                    taxplayercode, name, identifitime, exportvolume, exportvolumecurrency, workshop, staffnum, financialcontactor, financialtelephone,
                                    province, city, district, address, website, ischeckinfo, contactname, contacttel,certInfoBussinessLicense, certInfoReceipt, certInfoSaleCheck, certInfoTaxplayer,
                                    certInfoVATVoice, certInfoProtocal, certInfoOther, cstid,  memo, goodsproperty, foundeddate, certInfoTaxRegister
                                }) {
    return request(apiPath.mc + "/api/drawer", {
        method: 'post',
        data: {
            taxplayercode, name, identifitime, exportvolume, exportvolumecurrency, workshop, staffnum, financialcontactor, financialtelephone,
            province, city, district, address, website, ischeckinfo, contactname, contacttel,certInfoBussinessLicense, certInfoReceipt, certInfoSaleCheck, certInfoTaxplayer,
            certInfoVATVoice, certInfoProtocal, certInfoOther, cstid, memo, goodsproperty, foundeddate, certInfoTaxRegister
        }
    });
}


/**
 * 更新开票人
 * @param id
 * @param taxplayercode
 * @param name
 * @param identifitime
 * @param exportvolume
 * @param exportvolumecurrency
 * @param workshop
 * @param staffnum
 * @param financialcontactor
 * @param financialtelephone
 * @param province
 * @param district
 * @param address
 * @param website
 * @param ischeckinfo
 * @param contactname
 * @param contacttel
 * @param certInfoBussinessLicense
 * @param certInfoReceipt
 * @param certInfoSaleCheck
 * @param certInfoTaxplayer
 * @param certInfoVATVoice
 * @param certInfoProtocal
 * @param certInfoOther
 * @returns {Promise.<void>}
 */
export async function updateDrawer({
                                        id, taxplayercode, name, identifitime, exportvolume, exportvolumecurrency, workshop, staffnum, financialcontactor, financialtelephone,
                                       province, city, district, address, website, ischeckinfo, contactname, contacttel,certInfoBussinessLicense, certInfoReceipt, certInfoSaleCheck, certInfoTaxplayer,
                                       certInfoVATVoice, certInfoProtocal, certInfoOther,cstid,  memo, goodsproperty, foundeddate,certInfoTaxRegister, monthlylimit, ticketlimit

                                    }) {
    return request(apiPath.mc + "/api/drawer", {
        method: 'put',
        data: {
            id, taxplayercode, name, identifitime, exportvolume, exportvolumecurrency, workshop, staffnum, financialcontactor, financialtelephone,
            province, city, district, address, website, ischeckinfo, contactname, contacttel,certInfoBussinessLicense, certInfoReceipt, certInfoSaleCheck, certInfoTaxplayer,
            certInfoVATVoice, certInfoProtocal, certInfoOther,  memo, goodsproperty, foundeddate,certInfoTaxRegister, monthlylimit, ticketlimit
        }
    });
}

/**
 * 根据id查询开票人
 * @param id
 * @returns {Promise.<void>}
 */
export async function getDrawerById({id}) {
    return request(apiPath.mc + "/api/drawer/"+ id, {
        method: 'get'
    });
}



/**
 * 删除开票人
 * @param id
 * @returns {Promise.<void>}
 */
export async function deleteDrawerById({id}) {
    return request(apiPath.mc + "/api/drawer/"+ id, {
        method: 'delete'
    });
}


/**
 * 增加并提交审核开票人信息
 * @param taxplayercode
 * @param name
 * @param identifitime
 * @param exportvolume
 * @param exportvolumecurrency
 * @param workshop
 * @param staffnum
 * @param financialcontactor
 * @param financialtelephone
 * @param province
 * @param district
 * @param address
 * @param website
 * @param ischeckinfo
 * @param contactname
 * @param contacttel
 * @param certInfoBussinessLicense
 * @param certInfoReceipt
 * @param certInfoSaleCheck
 * @param certInfoTaxplayer
 * @param certInfoVATVoice
 * @param certInfoProtocal
 * @param certInfoOther
 * @param cstid
 * @returns {Promise.<void>}
 */
export async function addDrawerAndSubmit({
                                             taxplayercode, name, identifitime, exportvolume, exportvolumecurrency, workshop, staffnum, financialcontactor, financialtelephone,
                                             province, city, district, address, website, ischeckinfo, contactname, contacttel,certInfoBussinessLicense, certInfoReceipt, certInfoSaleCheck, certInfoTaxplayer,
                                             certInfoVATVoice, certInfoProtocal, certInfoOther, cstid,  memo, goodsproperty, foundeddate, certInfoTaxRegister
                                 }) {
    return request(apiPath.mc + "/api/"+ cstid +"/drawer/submit", {
        method: 'post',
        data: {
            taxplayercode, name, identifitime, exportvolume, exportvolumecurrency, workshop, staffnum, financialcontactor, financialtelephone,
            province, city, district, address, website, ischeckinfo, contactname, contacttel, certInfoBussinessLicense, certInfoReceipt, certInfoSaleCheck, certInfoTaxplayer,
            certInfoVATVoice, certInfoProtocal, certInfoOther,  memo, goodsproperty, foundeddate, certInfoTaxRegister
        }
    });
}

/**
 * 修改并提交审核开票人信息
 * @param id
 * @param taxplayercode
 * @param name
 * @param identifitime
 * @param exportvolume
 * @param exportvolumecurrency
 * @param workshop
 * @param staffnum
 * @param financialcontactor
 * @param financialtelephone
 * @param province
 * @param district
 * @param address
 * @param website
 * @param ischeckinfo
 * @param contactname
 * @param contacttel
 * @param certInfoBussinessLicense
 * @param certInfoReceipt
 * @param certInfoSaleCheck
 * @param certInfoTaxplayer
 * @param certInfoVATVoice
 * @param certInfoProtocal
 * @param certInfoOther
 * @returns {Promise.<void>}
 */
export async function updateDrawerAndSubmit({
                                                id, taxplayercode, name, identifitime, exportvolume, exportvolumecurrency, workshop, staffnum, financialcontactor, financialtelephone,
                                                province, city, district, address, website, ischeckinfo, contactname, contacttel, certInfoBussinessLicense, certInfoReceipt, certInfoSaleCheck, certInfoTaxplayer,
                                                certInfoVATVoice, certInfoProtocal, certInfoOther,cstid, memo, goodsproperty, foundeddate, certInfoTaxRegister
                                    }) {
    return request(apiPath.mc + "/api/"+ cstid +"/drawer/submit", {
        method: 'put',
        data: {
            id, taxplayercode, name, identifitime, exportvolume, exportvolumecurrency, workshop, staffnum, financialcontactor, financialtelephone,
            province, city, district, address, website, ischeckinfo, contactname, contacttel, certInfoBussinessLicense, certInfoReceipt, certInfoSaleCheck, certInfoTaxplayer,
            certInfoVATVoice, certInfoProtocal, certInfoOther,  website, memo, goodsproperty, foundeddate, certInfoTaxRegister
        }
    });
}


/**
 * 开票人审核
 * @param id
 * @param islookfactory
 * @param supplygoods
 * @param checkFactoryReport
 * @param approvalresult
 * @param approvalmemo
 * @returns {Promise.<void>}
 * @constructor
 */
export async function drawerApproval({id, islookfactory, supplygoods, checkFactoryReport, approvalresult, approvalmemo, ticketlimit, monthlylimit}) {
    let businesstype = "drawer";
    let entityid = id;

    return request(apiPath.mc + "/api/drawer/" + id + "/approval", {
        method: 'post',
        data: {
            id, islookfactory, supplygoods, checkFactoryReport, approvalresult, approvalmemo, businesstype, entityid, ticketlimit, monthlylimit
        }

    });

}

/**
 * 查询客户对应的境内货源地
 * @param cstId
 */
export async function getSupplygoodsByCstId({cstId}) {
    return request(apiPath.mc + "/api/drawer/supplygoods", {
        method: 'get',
        data: {cstId}
    });
}
